<template>
  <div class="tab-content">
    <div class="tab-main-content">
      <div class="search">
        <el-input
          placeholder="请输入停车场名称"
          v-model="input5"
          class="input-with-select"
          size="small"
        >
          <template slot="prepend">停车场</template>
          <el-button
            slot="append"
            icon="el-icon-search"
          ></el-button>
        </el-input>
      </div>
    </div>

    <div class="park-list">
      <el-checkbox-group
        v-model="checkedCities"
        @change="handleCheckedCitiesChange"
      >
        <div
          class="park-item"
          v-for="city in cities"
        >
          <div class="park-name item">
            <el-checkbox
              :label="city"
              :key="city"
            >{{city}}</el-checkbox>
          </div>

          <div class="qr-src item">
            <div class="title"> 二维码链接</div>

            <el-input
              :disabled="true"
              size="small"
            >
            </el-input>
          </div>

          <div class="actions item">
            <a href="javascript:;">复制链接</a>
            <a href="javascript:;">预览</a>
            <a href="javascript:;">车场显示信息</a>
          </div>

        </div>
      </el-checkbox-group>

      <div class="all-check">
        <el-checkbox
          :indeterminate="isIndeterminate"
          v-model="checkAll"
          @change="handleCheckAllChange"
        >全选</el-checkbox>
        <div class="checked-tips">
          已选择2个停车场
        </div>
      </div>

    </div>

    <el-button
      type="primary"
      size="small"
    >下载二维码</el-button>

    <div class="qr-tips">
      <div class="title">车场二维码-使用场景</div>
      <div class="tips-bd">
        单车场使用，支持对应车场在场车辆的查费缴费。
      </div>
    </div>

    <el-dialog
      title="编辑车场显示信息"
      :visible.sync="dialogVisible"
      width="600px"
      class="zb-dialog"
    >
      <div class="parkinglot-showInfo-content">
        <el-form
          :model="ruleForm"
          :rules="rules"
          ref="ruleForm"
          label-width="130px"
          size="small"
          class="zb-form"
        >
          <el-form-item label="停车场信息显示">
            <el-checkbox-group>
              <el-checkbox>停车场名称</el-checkbox>
              <el-checkbox>入场时间</el-checkbox>
              <el-checkbox>停车时长</el-checkbox>
            </el-checkbox-group>
          </el-form-item>
          <el-form-item
            label="停车场LOGO"
            prop=""
          >
            <el-upload
              class="upload-demo"
              action=""
              :on-change="handleChange"
              :before-upload="beforeAvatarUpload"
              :file-list="fileList2"
              list-type="picture"
            >
              <el-button
                size="small"
                type="primary"
              >选取图片</el-button>
              <div
                slot="tip"
                class="el-upload__tip"
              >* LOGO高度不超过150px，宽度不超过200px，建议上传png格式的文件。</div>
            </el-upload>
          </el-form-item>
        </el-form>
      </div>
      <span
        slot="footer"
        class="dialog-footer"
      >
        <el-button
          type="primary"
          size="medium"
          @click="dialogVisible = false"
        >确 定</el-button>
        <el-button
          size="medium"
          plain
          @click="dialogVisible = false"
        >取 消</el-button>
      </span>
    </el-dialog>

  </div>
</template>


<script>
const cityOptions = [
  "车场显示信息车场显示信息车场显示信息",
  "北京",
  "广州",
  "深圳"
];
export default {
  data() {
    return {
      input5: "",
      form: {},
      checkAll: false,
      checkedCities: ["上海", "北京"],
      cities: cityOptions,
      isIndeterminate: true,
      dialogVisible: true,
      ruleForm: {
        name: ""
      },
      rules: {
        name: [
          { required: true, message: "请输入激活码", trigger: "blur" }
          // { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ]
      },
      fileList2: [
        {
          name: "food.jpeg",
          url:
            "https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100"
        }
      ]
    };
  },
  methods: {
    handleCheckAllChange(val) {
      this.checkedCities = val ? cityOptions : [];
      this.isIndeterminate = false;
    },
    handleCheckedCitiesChange(value) {
      let checkedCount = value.length;
      this.checkAll = checkedCount === this.cities.length;
      this.isIndeterminate =
        checkedCount > 0 && checkedCount < this.cities.length;
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    },
    handleChange(file, fileList) {
      console.log(fileList);
      this.fileList2 = fileList.slice(-1);
    },
    beforeAvatarUpload(file) {
      return false;
      // const isJPG = file.type === 'image/jpeg';
      // const isLt2M = file.size / 1024 / 1024 < 2;

      // if (!isJPG) {
      //   this.$message.error('上传头像图片只能是 JPG 格式!');
      // }
      // if (!isLt2M) {
      //   this.$message.error('上传头像图片大小不能超过 2MB!');
      // }
      // return isJPG && isLt2M;
    }
  }
};
</script>

<style lang='less' scoped>
@import "./index.less";
</style>
